
<#-- 导入模版定义文件-->

<#include "../template/template_editPage.ftl">
<@edit title="操作员操作">
	<#if (operator.id)??>
		<#assign isEdit = true />
	<#else>
		<#assign isAdd = true />
	</#if>
	<body class="input">
	<script type="text/javascript">
	$().ready( function() {
	
		var $validateErrorContainer = $("#validateErrorContainer");
		var $validateErrorLabelContainer = $("#validateErrorContainer ul");
		var $validateForm = $("#validateForm");
		var $tab = $("#tab");
	
		// Tab效果
		$tab.tabs(".tabContent", {
			tabs: "input"
		});
		
		// 表单验证
		$validateForm.validate({
			errorContainer: $validateErrorContainer,
			errorLabelContainer: $validateErrorLabelContainer,
			wrapper: "li",
			errorClass: "validateError",
			ignoreTitle: true,
			rules: {
				"operator.pwd": {
						required: true,
					minlength: 4,
					maxlength: 	 20
				},
				"repwd": {
						required: true,
					equalTo: "#password"
				},
				"operator.email": {
					required: true,
					email: true
				},
				"operator.tel": {
					required: true,
					mobile: true
				}
			},
			messages: {
				"operator.pwd": {
						required: "请填写密码",
					minlength: "密码必须大于等于4",
					maxlength: 	 "密码必须小于等于20"
				},
				"repwd": {
						required: "请填写重复密码",
					equalTo: "两次密码输入不一致"
				},
				"operator.email": {
					required: "请填写E-mail",
					email: "E-mail格式不正确"
				},
				"operator.tel": {
					required: "请填写手机",
					mobile: "手机格式不正确"
				}				
			},
			submitHandler: function(form) {
				$(form).find(":submit").attr("disabled", true);
				form.submit();
			}
		});
		<#if actionErrors??&&(actionErrors?size > 0)>
			$.dialog({type: "warn", content: "<#list errorMessages as list>${list}<br></#list>", modal: true, autoCloseTime: 3000});
		</#if>
	});
	</script>
		<div class="body">
			<div class="inputBar">
				<h1><span class="icon">&nbsp;</span><#if isAdd??>添加管理员<#else>编辑管理员</#if></h1>
			</div>
			<div style="display: none;" id="validateErrorContainer" class="validateErrorContainer">
				<div class="validateErrorTitle">以下信息填写有误,请重新填写</div>
				<ul></ul>
			</div>			
			<form id="validateForm" class="validate" method="post" action="<#if isAdd??>${web_base}/system/admin!adduser.htm<#else>${web_base}/system/admin!editUser.htm</#if>">
			<table class="inputTable tabContent">
			<tr>

				<th>操作员账号:</th>
				<td><#if isAdd??><input type="text" name="operator.account" class="formText {required: true, username: true, remote:'admin!checkUsername.htm', minlength: 2, maxlength: 20, messages: {remote: '用户名已存在,请重新输入!'}}" 
				    value=""><label class="requireField">*</label><#else>${(operator.account)!}<input type="hidden" name="operator.account" 
				    value="${(operator.account)!}" /></#if></td>
			</tr>
			<#if isAdd??>
			<tr>
				<th>操作员密码:</th>
				<td><input type="password" name="operator.pwd" id="password" class="formText" value=""><label class="requireField">*</label></td>
			</tr>
			<tr>
				<th>重复操作员密码:</th><td><input type="password" name="repwd" class="formText" value=""><label class="requireField">*</label></td>
			</tr>
			</#if>
			<tr>
				<th>所属角色:</th><td><select name="operator.roleId">
				<#if operator??&&operator.role??>
				<#list operator.role as row>
				<option value="${(row.id)!}" <#if isEdit??><#if operator.roleId=="${(row.id)!}" >selected="selected"</#if></#if>>${(row.name)!}</option>
				</#list>
				</#if>
				</select></td>
			</tr>
			<tr>
				<th>操作员类型:</th><td><select name="operator.type">
				<option value="0" <#if isEdit??><#if operator.type=="0" >selected="selected"</#if></#if> >员工</option>
				<option value="1" <#if isEdit??><#if operator.type=="1" >selected="selected"</#if></#if> >运营商</option>
				<option value="2" <#if isEdit??><#if operator.type=="2" >selected="selected"</#if></#if> >代理商</option>
				<option value="3" <#if isEdit??><#if operator.type=="3" >selected="selected"</#if></#if> >商户</option>
				<option value="4" <#if isEdit??><#if operator.type=="4" >selected="selected"</#if></#if> >银行</option>
				<option value="5" <#if isEdit??><#if operator.type=="5" >selected="selected"</#if></#if> >企业</option>
				<option value="6" <#if isEdit??><#if operator.type=="6" >selected="selected"</#if></#if> >其他</option>
				</select></td>
			</tr>
			<tr>
				<th>操作员email:</th>
				<td><input type="text" name="operator.email" class="formText"  value="${(operator.email)!}"><label class="requireField">*</label></td>
			</tr>
			<tr style="display:none">
				<th>状态:</th>
				<td><input type="text" name="operator.state" value="0" ><label class="requireField">*</label></td>
			</tr>
				<th>操作员电话:</th>
				<td><input type="text" id="tel"  class="formText" name="operator.tel" value="${(operator.tel)!}" ><label class="requireField">*</label></td>
			</tr>
			</table>
			<div class="buttonArea">
				<input type="submit" class="formButton" value="<#if isAdd??>注册<#else>修改</#if>" hidefocus="true" />&nbsp;&nbsp;&nbsp;&nbsp;
				<input type="button" class="formButton" onclick="window.history.back(); return false;" value="返  回" hidefocus="true" />
			</div>
			<input type="hidden" name="operator.id"value ="${(operator.id)!}">
            </form>
		</div>
	</body>

</@edit>